<?php

namespace App\Http\Managers;

use SoapClient;
use SoapFault;

class MySoap  extends SoapClient
{
    public function __construct($wsdl, $options = array()) {
        parent::__construct($wsdl, $options);
    }
   
    /**
     * Call a url using curl with ntlm auth
     *
     * @param string $url
     * @param string $data
     * @return string
     * @throws SoapFault on curl connection error
     */
    protected function callCurl($url, $data) {
    $handle   = curl_init();
    curl_setopt($handle, CURLOPT_HEADER, false);
    curl_setopt($handle, CURLOPT_URL, $url);
    curl_setopt($handle, CURLOPT_FAILONERROR, true);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
    $response = curl_exec($handle);
	var_dump($response);
    if (empty($response)) {
      throw new SoapFault('CURL error: '.curl_error($handle),curl_errno($handle));
    }
    curl_close($handle);
    return $response;
    }
   
    public function __doRequest($request,$location,$action,$version,$one_way = 0) {
        return $this->callCurl($location,$request);
    }

}
